﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using Hydra.Contract;

namespace Hydra.Payload
{
    public class Engine
    {
        private static IHydraService service;

        public static IHydraService Proxy { get { return service; } }

        public static void Start()
        {
            HydraClient client = new HydraClient();
            service = DuplexChannelFactory<IHydraService>.CreateChannel(client,
                Constants.Binding, new EndpointAddress(Constants.Endpoint));

            //订阅消息
            service.RegisterListener();
            service.WriteLog(LogLevel.Info, "Client start...");
            Console.WriteLine("Client started and listener registered.");

            //Console.WriteLine("Press enter key to exit.");
            //Console.ReadLine();

        }

        public static void Stop()
        {
            service.WriteLog(LogLevel.Info, "Client stop...");
            service.UnregisterListener();
            Console.WriteLine("Client stopped.");
        }
    }
}
